using QFramework;
using System.Collections.Generic;
using UnityEngine;

namespace ProjectSurvivor
{
    public class SaveSystem : AbstractSystem
    {
        public void Save()
        {

        }
        public void Load()
        {

        }
        private HashSet<string> Keys = new HashSet<string>();
        public void SaveBool(string key, bool Value = false)
        {
            Keys.Add(key);
            PlayerPrefs.SetInt(key, Value ? 1 : 0);
        }
        public bool LoadBool(string key, bool Value = false)
        {
            Keys.Add(key);
            return PlayerPrefs.GetInt(key, Value ? 1 : 0) == 1;
        }
        public void SaveInt(string key, int Value=0)
        {
            Keys.Add(key);
            PlayerPrefs.SetInt(key, Value);
        }
        public int LoadInt(string key, int Value = 0)
        {
            Keys.Add(key);
            return PlayerPrefs.GetInt(key, Value);
        }
        public void SaveFloat(string key, float Value = 0)
        {
            Keys.Add(key);
            PlayerPrefs.SetFloat(key, Value);
        }
        public float LoadFloat(string key, float Value = 0)
        {
            Keys.Add(key);
            return PlayerPrefs.GetFloat(key, Value);
        }
        public void SaveString(string key, string Value = "")
        {
            Keys.Add(key);
            PlayerPrefs.SetString(key, Value);
        }
        public string LoadString(string key, string Value = "")
        {
            Keys.Add(key);
            return PlayerPrefs.GetString(key, Value );
        }
        protected override void OnInit()
        {
            ActionKit.OnGUI.Register(() => 
            {
                if(Input.GetKey(KeyCode.L))
                {
                    foreach (var key in Keys)
                    {
                        GUILayout.Label(key+":"+PlayerPrefs.GetInt(key));
                        GUILayout.Label(key+":"+PlayerPrefs.GetString(key));
                        GUILayout.Label(key+":"+PlayerPrefs.GetFloat(key));
                    }
                }
            });
        }
    }
}